﻿<%@ Page Title="Discussions" Language="C#" MasterPageFile="~/Master/BookClub.Master" AutoEventWireup="true" CodeBehind="discussions.aspx.cs" Inherits="BookClubIt.discussions" %>
  <%@ Register TagPrefix="uc" TagName="clubnav" Src="~/UserControls/clubmenu.ascx" %>
  <%@ Register TagPrefix="uc" TagName="joinbox" Src="~/UserControls/joinbox.ascx"  %>
  <%@ Register TagPrefix="uc" TagName="currentbook" Src="~/UserControls/currentbook.ascx"  %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

  <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
  <script type="text/javascript">
      $(document).ready(function () {
      
          $("#createTopicform").click(function () {
          var topicName = $('#topicName').val();
          var bid = $('#MainContent_hdnBid').val();
          $.ajax({
              type: "POST",
              url: "../AjaxFunctions.asmx/CreateTopic",
              data: '{Topic_Title : "' + topicName + '", BookClub_Id : "' + bid + '"}',
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function (msg) {
                  alert(msg.d);
              }
          });
      });


 });
  </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 <asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:HiddenField ID="hdnBid" runat="server" />
<div class="row">
<div class="left-nav">
<uc:clubnav id="clubnav"  runat="server" />
</div>

<div class="content">
<h1><small><asp:label ID="lblClubName" runat="server" /> Discussions</small></h1>
<p class="help-block">Below are your discussions about <asp:HyperLink ID="lnkCurrentTitle" runat="server" Text="" NavigateUrl="" />. Click 'create topic' to create a new topic for this book.</p>
<asp:Panel ID="pnlNoCurrentBook" runat="server" CssClass="no-results">
<h3>You dont not have a current book to discuss</h3>
<p>You cannot add a topic until you choose a book to read. Go to the book shelf and update your current book.</p>
</asp:Panel>
    <asp:Button ID="btnOpenModal" runat="server" Text="Add Topic" CssClass="btn btn-primary" Visible="false" />
        <asp:Panel ID="popupPanel" runat="server" Style="display: none" CssClass="popup" Height="400px" Width="500px">
            <asp:Button ID="cancelbutton" runat="server" Text="x" CssClass="close-button" />
     
<h3>Add a topic</h3>
 <form class="well form-inline">
           <asp:TextBox ID="txtTopicName" runat="server" CssClass="span4" placeholder="Topic name" />
  <p class="help-block">Enter a topic to discuss. Ex. Chapter 1</p>
  <asp:Button ID="btnCreateTopic" runat="server" CssClass="btn btn-success" OnClick="btnCreateTopic_Click" Text="Create Topic" />
    </form>
  </asp:Panel>
     
       

        <cc1:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="mpe" runat="server"
            PopupControlID="popupPanel" CancelControlID="cancelbutton" Enabled="True" TargetControlID="btnOpenModal"
            BackgroundCssClass="modalBackground2">
        </cc1:ModalPopupExtender>


<asp:panel ID="pnlNoDiscussions" runat="server" CssClass="alert alert-danger" Visible="false">
<p>Sorry, there are no discussions or topics. Please create a topic to start a discussion.</p>
</asp:panel>


<asp:GridView ID="grdDiscussionTopics"
 OnRowDataBound="grdDiscussionTopics_OnRowDataBound"
  runat="server"
   AutoGenerateColumns="false"
    AlternatingRowStyle-CssClass="alt"
     CssClass="table table-striped discussion-topics"
     GridLines="None">
<Columns>


    <asp:TemplateField HeaderStyle-CssClass="main-link" ItemStyle-CssClass="main-link">
           <HeaderTemplate >
             Topic
           </HeaderTemplate>
           <ItemTemplate>
           <asp:HyperLink ID="lnkTopic" runat="server" />
           
           </ItemTemplate>
      </asp:TemplateField>

          <asp:TemplateField>
           <HeaderTemplate>
                Posts
           </HeaderTemplate>
           <ItemTemplate>
            <asp:Label ID="lblPostCount" runat="server" />
           </ItemTemplate>
      </asp:TemplateField>

        <asp:TemplateField>
           <HeaderTemplate>
                About
           </HeaderTemplate>
           <ItemTemplate>
          <asp:Label ID="lblPostAbout" runat="server" />
           </ItemTemplate>
      </asp:TemplateField>

        <asp:TemplateField>
           <HeaderTemplate>
                Last Activity
           </HeaderTemplate>
           <ItemTemplate>
          <asp:Label ID="lblRecentActivity" runat="server" /> <asp:HyperLink ID="lnkLatestCommentMember" runat="server" />
           </ItemTemplate>
      </asp:TemplateField>

</Columns>
</asp:GridView>


</div>
<div class="right-sidebar">
<uc:joinbox id="joinbox"  runat="server" />

<uc:currentbook id="currentbook"  runat="server" />


 <script type="text/javascript"><!--
     google_ad_client = "ca-pub-1776925204000985";
     /* bci_250_right */
     google_ad_slot = "4159600899";
     google_ad_width = 250;
     google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

<asp:Panel ID="pnlOtherDiscussions" runat="server">
 <h2><small>Other Discussions</small></h2>
 <asp:Repeater ID="rptAllDiscussions" OnItemDataBound="rptAllDiscussions_OnItemDataBound"  runat="server">
 <HeaderTemplate><asp:Label ID="lblPrevBookTitle" runat="server"/><ul class="prev-discussions"></HeaderTemplate>
  <ItemTemplate>
 <li><asp:HyperLink ID="lnkprevioustopic" runat="server" /></li>
  </ItemTemplate>
  <FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
</asp:Panel>
</div>

</div>
</asp:Content>
